<?php
/**
* Django's templating engine (partial) PHP implementation.
* provides some template tags support
* @link http://djangoproject.com
* this file is from a webappkit package (kit)
* @link http://webappkit.net
* @package djtpl
* @author J.Ducastel <nospam0@ducastel.name>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

/**
* 'extends' tag node.
* <code>{% extends "parent" %}</code>
*/
class DjTplTagNode_block extends DjTplTagNode {

    /**
     * @var string block's name
     */
    var $name;

    /**
    * builds itself from tokens
    * @param djangoTplToken &$selfToken
    * @param array &$nextTokens djangoTplToken
    * @access public
    * @return bool
    */
    function buildFromTokens(&$selfToken,&$nextTokens) {
        $def=$selfToken->tagdef;
        $regex='([a-zA-Z0-9\._-]+)';
        if (ereg($regex,$def,$search)) {
            $this->name=$search[1];
        } else {
            // error !
            trigger_error('invalid structure for tag block : '.$def);
        }
        $this->buildChildNodesFromTokens($nextTokens);
        // echo '<pre>'; print_r($nextTokens);
        return true;
    }

    function isBlock() {
        return $this->name;
    }

    function isAtomic() {
        return false;
    }

    /**
    * renders as string
    * @param djangoTplContext $context
    * @access public
    * @return string
    */
    function render(&$context) {
        //echo "<p>rendering block {$this->name}</p><pre>";
        // echo '<pre>'; print_r($context);
        return $this->renderChildNodes($context);
    }
}
